package collection;

import java.util.ArrayList;
import java.util.Iterator;

public class IteratorDemo1 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("222");
        list.add("222");
        list.add("222");
        list.add("222");
        list.add("333");
        //将集合交给迭代器,最开始指向0索引
        Iterator<String> it =  list.iterator();
        while(it.hasNext()){
            String next = it.next();
            if(next.equals("333")){
                it.remove();
            }
        }
        System.out.println(list);
    }
}
